﻿using System.Xml.Linq;

namespace Songhay.OpenXml.Transformations
{
    /// <summary>
    /// Defines extension methods for
    /// <see cref="IWordProcessingDocumentTransformation"/>.
    /// </summary>
    public static class IWordProcessingDocumentTransformationExtensions
    {
        /// <summary>
        /// Determines whether the node
        /// has the specified <see cref="System.Xml.Linq.XName"/>.
        /// </summary>
        /// <param name="transformation">The transformation.</param>
        /// <param name="node">The node.</param>
        /// <param name="name">The name.</param>
        /// <returns>
        /// 	<c>true</c> when the node has the name; otherwise, <c>false</c>.
        /// </returns>
        public static bool HasElementName(this IWordProcessingDocumentTransformation transformation, XNode node, XName name)
        {
            var element = node as XElement;
            return (element != null) && (element.Name == name);
        }
    }
}
